import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import path from 'path'

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue', 'vue-router', 'pinia'],
      dts: false,
      eslintrc: {
        enabled: false, // 默认false, true启用。生成一次就可以，避免每次工程启动都生成
        filepath: './.eslintrc-auto-import.json', // 生成json文件
        globalsPropValue: true,
      },
    }),
  ],
  resolve: {
    alias: {
      '@': path.resolve('./src'), //修改相对路径使用@
    },
  },
  server: {
    proxy: {
      '/api': {
        target: "http://localhost:3000/adminapi",
        changeOrigin: true,
        rewrite: (p: string) => p.replace(/^\/api/, '')
      }
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        //清除scss高版本报错
        api: 'modern-compiler', // or 'modern'
        // javascriptEnable: true,
        additionalData: '@use "@/styles/variable.scss" as *;',
      },
    },
  },
})
